package com.vcc.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.vcc.data.entity.BossUserBossRole;
import com.vcc.data.mapper.BossUserBossRoleMapper;
import com.vcc.service.service.BossUserBossRoleService;
import org.springframework.stereotype.Service;

@Service
public class BossUserBossRoleServiceImpl extends ServiceImpl<BossUserBossRoleMapper, BossUserBossRole> implements BossUserBossRoleService {
    @Override
    public Boolean init(Long userId, Long roleId) {
        BossUserBossRole bossUserBossRole = new BossUserBossRole();
        bossUserBossRole.setBossRoleId(roleId);
        bossUserBossRole.setUserId(userId);
        save(bossUserBossRole);
        return true;
    }

    @Override
    public Boolean updateUserRole(Long userId, Long roleId) {
        return updateChain()
                .set(BossUserBossRole::getBossRoleId, roleId)
                .eq(BossUserBossRole::getUserId, userId)
                .update();
    }
}
